<template>
	<view class="content">
		<!-- 免费券 -->
		<view class="fenlei" v-show="data.freeList.length">
			<view class="q-top flex-justify-s">
				<text class="title">免费券</text>
				<view @click="more(1)" class="flex-justify-center">
					<text class="more">更多</text>
					<uv-icon name='arrow-right' size="10" color="#2C2C2C"></uv-icon>
				</view>
			</view>
			<view class="">
				<view class="coupon-item" v-for="(item,index) in data.freeList" :key="index">
					<view class="quan flex-align-center">
						<view class="pq-box">
							<text class="num">{{item.type.code==3?item.discount:item.ticketValue}}<text
									class="fuhao">{{item.type.code==3?'折':'￥'}}</text>
							</text>
						</view>
						<view class="line"></view>
						<view class="quan-sm">
							<text>{{item.type.value}}</text>
							<text>满{{item.threshold}}元可用</text>
						</view>
						<navigator :url="`/pages/subpackagesSon/coupon/buyNow/buyNow?id=${item.id}`" hover-class="none"
							class="draw-down">点击领取</navigator>
					</view>
				</view>
			</view>
		</view>
		<!-- 购买券 -->
		<view class="" v-show="data.tollList.length">
			<view class="q-top flex-justify-s">
				<text class="title">购买券</text>
				<view class="flex-justify-center" @click="more(2)">
					<text class="more">更多</text>
					<uv-icon name='arrow-right' size="10" color="#2C2C2C"></uv-icon>
				</view>
			</view>
			<view class="goumaiquan">
				<view class="coupon-item" v-for="(item,index) in data.tollList" :key="index">
					<view class="quan flex-align-center">
						<view class="gmj-left">
							<text class="num">{{item.type.code==3?item.discount:item.ticketValue}}<text
									class="fuhao">{{item.type.code==3?'折':'￥'}}</text></text>
							<text class="jg">{{item.type.code==1?'':'价格：¥'+item.price}}</text>
						</view>

						<view class="line"></view>
						<view class="quan-sm">
							<text>{{item.type.value}}</text>
							<text>满{{item.threshold}}元可用</text>
						</view>
						<navigator hover-class="none" :url="`/pages/subpackagesSon/coupon/buyNow/buyNow?id=${item.id}`"
							class="draw-down">立即购买</navigator>
					</view>
				</view>

			</view>

		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from "vue";
	import {
		onShow,
		onLoad
	} from "@dcloudio/uni-app";
	import {
		getTicketByEntId
	} from '../../../../requestApi/api.js';
	const data = ref({
		freeList: [], //免费券
		tollList: [], //收费券
		id: '',
	})
	onLoad((e) => {
		data.value.id = e.id;
		getList();
	})
	onShow(() => {

	})

	//更多
	const more = (type) => {

		//免费券
		uni.navigateTo({
			url: `/pages/subpackagesSon/coupon/couponList/couponList?type=${type}&id=${data.value.id}`
		})

	};
	// 获取优惠券
	function getList() {
		getTicketByEntId({
			id: data.value.id
		}).then(res => {
			data.value.freeList = res.data.freeList;
			data.value.tollList = res.data.tollList;

		})
	};
</script>

<style lang="scss">
	.content {
		padding: 48rpx 72rpx;

		.fenlei {
			margin-bottom: 10rpx;
		}

		.q-top {
			margin-bottom: 28rpx;

			.title {
				font-size: 32rpx;
				font-weight: bold;
				color: #2C2C2C;
			}

			.more {
				font-size: 26rpx;
				color: #A5A5A5;
				margin-right: 18rpx;
			}
		}


		.coupon-item {
			width: 280rpx;
			height: 100rpx;
			position: relative;
			background: url('../../../../static/img/img/club-yhq-bg.png') no-repeat;
			background-size: cover;
			display: inline-block;
			margin-right: calc(100vw - 704rpx);
			margin-bottom: 22rpx;


			.quan {
				height: 100%;
				padding-left: 14rpx;

				.pq-box {
					width: 78rpx;

					.num {
						font-size: 48rpx;
						font-weight: bold;
						color: #F26D61;
						letter-spacing: -4rpx;
						font-family: DINCond-Black;
						position: relative;
						width: max-content;

						.fuhao {
							font-size: 20rpx;
							color: #F26D61;
							position: absolute;
							top: 0;
						}
					}
				}

				.line {
					height: 46rpx;
					width: 2rpx;
					background-color: rgba(242, 108, 97, .2);
					margin: 0 6rpx 0 24rpx;
				}

				.quan-sm {
					font-size: 18rpx;
					color: #F26D61;
					display: flex;
					flex-direction: column;

					text {
						// margin-bottom: 5rpx;
					}
				}
			}

			.draw-down {
				position: absolute;
				right: 0;
				top: 0;
				font-size: 18rpx;
				color: #FFFFFF;
				width: 30rpx;
				line-height: 20rpx;
				height: 100rpx;
				display: flex;
				align-items: center;
			}
		}

		/* 优惠券 */
		.goumaiquan {


			.coupon-item {
				width: 584rpx;
				height: 210rpx;
				position: relative;
				background: url('../../../../static/img/img/yhq-bg.png') no-repeat;
				background-size: cover;
				margin-bottom: 22rpx;


				.quan {
					height: 100%;
					padding-left: 34rpx;

					.gmj-left {
						display: flex;
						flex-direction: column;
						width: 170rpx;

						.jg {
							font-size: 24rpx;
							color: #F26D61;
							margin-left: 16rpx;
						}
					}

					.num {
						font-size: 96rpx;
						font-weight: bold;
						color: #F26D61;
						letter-spacing: -4rpx;
						font-family: DINCond-Black;
						position: relative;
						line-height: 90rpx;
						width: max-content;
						padding-right: 14rpx;

						.fuhao {
							font-size: 48rpx;
							color: #F26D61;
							position: absolute;
							top: -20rpx;
							right: -30rpx;
						}
					}

					.line {
						height: 96rpx;
						width: 2rpx;
						background-color: rgba(242, 108, 97, .2);
						margin: 0 14rpx 0 40rpx;
					}

					.quan-sm {
						font-size: 24rpx;
						color: #F26D61;
						display: flex;
						flex-direction: column;

						text {
							margin-bottom: 8rpx;
						}
					}
				}

				.draw-down {
					position: absolute;
					right: 0;
					top: 0;
					font-size: 32rpx;
					color: #FFFFFF;
					width: 56rpx;
					line-height: 36rpx;
					height: 210rpx;
					display: flex;
					align-items: center;
				}
			}

		}

		.coupon-item:nth-last-child(2n) {
			margin-right: 0;
		}


	}

	::v-deep .uv-icon__icon {
		font-weight: bold !important;
	}
</style>